/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package network;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author marcio
 */
public class GreenModule {
    
    //Alienware's mac = 5c:26:0a:17:ae:84
    
    //SÓ É VÁLIDO PARA LAN's CABEADAS
    public static void wakeOnLan(String macAddress){
       
        //Objeto para executar comando do shell
        Runtime runtime = Runtime.getRuntime();
        //Pegando o processo 
        Process process;
        try {
            //Executa o processo
            process = runtime.exec("powerwake " + macAddress);
            //process = runtime.exec("sudo rtcwake -u -s 60 -m mem");
            
            //Pega a mensagem do shell
            InputStream is = process.getInputStream();
            //Imprime do Buffer
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            
            //Impressão (para testes)
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        } 
        catch (IOException ex) {
            Logger.getLogger(GreenModule.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
}
